//  This file is part of MuMax, a high-performance micromagnetic simulator.
//  Copyright 2011  Arne Vansteenkiste and Ben Van de Wiele.
//  Use of this source code is governed by the GNU General Public License version 3
//  (as published by the Free Software Foundation) that can be found in the license.txt file.
//  Note that you are welcome to modify this code under the condition that you do not remove any 
//  copyright notices and prominently state that you modified it, giving a relevant date.

package frontend

import (
	"reflect"
	"unicode"
	"strings"
)

// Adds all public methods of receiver to map
// INTERNAL, but needed by package apigen
func AddMethods(methods map[string]reflect.Value, receiver_ interface{}) {
	receiver := reflect.ValueOf(receiver_)
	typ := reflect.TypeOf(receiver_)
	for i := 0; i < typ.NumMethod(); i++ {
		name := typ.Method(i).Name
		if unicode.IsUpper(int(name[0])) {
			methods[ConvertCase(name)] = receiver.Method(i)
		}
	}
}

// converts a function name in Go-style casing to the case we want in the API
func ConvertCase(funcName string) string {
	return strings.ToLower(funcName)
}
